#pragma once
#include "BKDE.h"

struct PARSE_RESULT
{
	ULONGLONG imageSize;
	ULONGLONG nBaseOffset;
	IMAGE_TYPES imageOSType;
	BOOL bImageBootable;
	CString strName;

	PARSE_RESULT()
	{
		clear();
	}

	~PARSE_RESULT()
	{
		this->strName.Empty();
	}

	void clear(void)
	{
		this->nBaseOffset = this->imageSize = 0;
		this->imageOSType = IMAGE_TYPE_UNKNOWN;
		this->bImageBootable = FALSE;
		this->strName = _T("");
	}

	PARSE_RESULT(const PARSE_RESULT *src)
	{
		this->imageSize = src->imageSize;
		this->nBaseOffset = src->nBaseOffset;
		this->imageOSType = src->imageOSType;
		this->bImageBootable = src->bImageBootable;
		this->strName = src->strName;
	}

	PARSE_RESULT &operator = (const PARSE_RESULT &src)
	{
		this->imageSize = src.imageSize;
		this->nBaseOffset = src.nBaseOffset;
		this->imageOSType = src.imageOSType;
		this->bImageBootable = src.bImageBootable;
		this->strName = src.strName;
		return *this;
	}
};

class CBKParseImage
{
		static const char *strID_Andos;
		static const char *strID_DXDOS;
		static const char *strID_FAT12;
		static const char *strID_Aodos;
		static const char *strID_Nord;
		static const char *strID_RT11;
		static const char *strID_RT11Q;
	public:
		CBKParseImage(void);
		~CBKParseImage(void);
		PARSE_RESULT    ParseImage(const CString &fname, ULONGLONG nBaseOffset);

	protected:
		BOOL            charcompare(BYTE a, BYTE b);
		BOOL            substrfind(BYTE *bufs, size_t len_bufs, BYTE *buff, size_t len_buff);
		int             IsCSIDOS3(CFile *f, ULONGLONG nBaseOffset, BYTE *buf);
		int             IsRT11_old(CFile *f, ULONGLONG nBaseOffset, BYTE *buf);
		int             IsRT11(CFile *f, ULONGLONG nBaseOffset, BYTE *buf);
};

